import axios from 'axios'
import globalConfig from '../config/globalConfig';
const service = axios.create({
  baseURL: globalConfig.baseAssetsUrl, // 从环境变量获取基础URL
  timeout: 5000
});

// 请求拦截器
service.interceptors.request.use(
  config => {
    // 可以在这里添加token等认证信息
    return config;
  },
  error => {
    console.log(error);
    return Promise.reject(error);
  }
);

// 响应拦截器
service.interceptors.response.use(
  response => {
    const res = response.data;
    return res;
  },
  error => {
    console.log('err' + error);
    return Promise.reject(error);
  }
);

export default service;


